/*
 ============================================================================
 Name		: TradeBlockQueryFunds.h
 Author	  : spring xu
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CTradeBlockQueryFunds declaration
 ============================================================================
 */

#ifndef TRADEBLOCKQUERYDELIVERY_H
#define TRADEBLOCKQUERYDELIVERY_H

// INCLUDES
#include "TradeBlock.h"
#include "Control.h"
#include "TableWidget.h"
#include "TradeBlockNetwork.h"

// CLASS DECLARATION

class CTradeBlockQueryDelivery: public CTradeBlock, public MWidgetObserver, public MPushButtonObserver //, public MReqObserver
{
public:
    ~CTradeBlockQueryDelivery();

    static CTradeBlockQueryDelivery* NewL(CBaseBlock* bsBack);

    static CTradeBlockQueryDelivery* NewLC(CBaseBlock* bsBack);
public:
	enum TQueryStatus
	{
		EQueryStatus_Query,
		EQueryStatus_Result,
	};
	
private:
    CTradeBlockQueryDelivery(CBaseBlock* bsBack);

    void ConstructL();

public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged();    
    
    //void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    void ChangeFocus(TBool aFocus, const TInt& keyCode);
    
    void BeforeBack();
    
    //void InitData();
	void OnInput(const TDesC8& strInput);
    
protected:
    void AddTabs();

    void BeforeDraw(CFbsBitGc& g) const;
    
private:
    void CreateTable();
    
public:
    // from MWidgetObserver
    void UpdateScreen();
    
    void SelectOneRow(TInt aRowIndex);
    
    void LoseFocus(const TInt& keycode);
    
    
public:// MPushButtonObserve
    void PushButtonClicked();
    
public:
	TBool ProcessTradeNetworkMsg(TInt nError, TAny* p, const TDesC8& aBodyData);
	//TBool UpdateTradeNetwork(TInt nProgress);
		
private:
	void CreateControls();
    void LayoutControls();
    void ResetControlDate();
    
    void InitNetworkData();
    TBool AppendNetworkData(__delivery_info_t* p_sDelivery);
    
private:
	enum TControlType
	{
		EControlType_BegineDate,
		EControlType_EndDate,
		EControlType_ButtonConfirm,
		EControlType_ButonReset,
		EControlTypeCount
	};
	enum TNetworkStatus
	{
		ENetworkStatus_None,
		ENetworkStatus_Req,
		ENetworkStatus_Resp
	};
private:
    CTableWidget* iTable;
    
    TInt iQueryStatus;
    
    CSingleLineTextInput* 	iBeginDate;
    CSingleLineTextInput*	iEndDate;
    CPushButton*		iButtonConfirm;
    CPushButton*		iButtonReset;
    
    CControl*	iControls[EControlTypeCount];
    TInt iFocusControl;
    
    CPushButton*		iButtonMore;
    TBool				iCanReq;
    
    TInt iNetworkStatus;
    TInt iNumberOfElement;
};

#endif // TRADEBLOCKQUERYHISTORYDELIVERY_H
